package soundwave.com.demo.adpater;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import soundwave.com.demo.R;
import soundwave.com.demo.test.Shoppingcontent_test;

/**
 * Created by xu on 2017/3/25.
 */

public class ShoppingList_adapert extends ArrayAdapter<Shoppingcontent_test> {
    private Context context;
    private int layoutid;
    private LayoutInflater inflater=null;


    public ShoppingList_adapert(@NonNull Context context, @LayoutRes int resource,ArrayList<Shoppingcontent_test> shoppingcontent) {
        super(context, resource,shoppingcontent);
        this.context=context;
        this.layoutid=resource;


    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View view=convertView;
        if (view==null){
            inflater=LayoutInflater.from(context);
            view=inflater.inflate(layoutid,null);
        }


        Shoppingcontent_test test=getItem(position);

        TextView title= (TextView) view.findViewById(R.id.itemnames);
        TextView adress= (TextView) view.findViewById(R.id.address);
        TextView money= (TextView) view.findViewById(R.id.moneny);


        title.setText(test.getTitle());
        adress.setText(test.getAddress());
        money.setText(String.valueOf(test.getMoney()));
        return view;
    }
}
